<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 构造函数版
      function CreateDog(name, type, age, color) {
        this.name = name;
        this.type = type;
        this.age = age;
        this.color = color;
        this.canDo();
      }
      CreateDog.prototype = {
        canDo() {
          console.log(
            `${this.name},${this.type},${this.age}岁,${this.color}，会汪汪叫，摇尾巴`
          );
        },
      };

      var dog1 = new CreateDog("可可", "阿拉斯加", "5", "红色");

      // 普通版
      var dog = {
        name: "可可",
        type: "阿拉斯加",
        age: "5",
        color: "红色",
        canDo() {
          console.log("汪汪汪汪汪汪汪汪汪汪汪汪汪汪汪！！！！！");
        },
      };
      console.log(dog);
    </script>
  </body>
</html>
